package moe.entity;

import java.util.Date;
import java.util.List;

public class Pool {
	private Long id;
	private String name;
	private String description;
	@Column(name = "post_count")
	private int count;
	private Long user_id;
	private int created_at;
	private int updated_at;
	@Transient
	private List<Post> posts;

	public Pool() {
	}

	public Pool(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public List<Post> getPosts() {
		return posts;
	}

	public void setPosts(List<Post> posts) {
		this.posts = posts;
	}

	public Date getCreatedDate() {
		return new Date(created_at * 1000l);
	}

	public Date getUpdatedDate() {
		return new Date(updated_at * 1000l);
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (this == obj) {
			return true;
		}
		if (!(obj instanceof Pool)) {
			return false;
		}
		Pool pool = (Pool) obj;
		if (pool.getId().equals(this.id)) {
			return true;
		}
		return false;
	}

	@Override
	public int hashCode() {
		return id.intValue();
	}
}
